package Jd;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ResourceBundle;

public class MainServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String key = request.getParameter("key");
        ResourceBundle resourceBundle = ResourceBundle.getBundle("jd");
        String value = resourceBundle.getString(key);
        try {
            Class clz = Class.forName(value);
            Method method = clz.getDeclaredMethod("execute", HttpServletRequest.class, HttpServletResponse.class);
            Object object = clz.newInstance();
            method.invoke(object, request, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
